package com.dev.security.login.service.filters;

import com.dev.security.login.service.UserService;
import com.dev.security.login.service.ValidateFilter;
import com.dev.security.login.service.ValidateInvocation;
import com.dev.security.login.util.LoginConstants;
/**
 * 权限过滤
 * @author <b>DEVILIVED</b>
 * <br/>E-Mail：3375758@qq.com
 * <br/>创建时间： 2014年6月28日 下午10:29:24 
 * @version V1.0
 */
public class ForbidFilter implements ValidateFilter {
	
	private UserService userService;
	
	public ForbidFilter(UserService userService) {
		this.userService = userService;
	}

	@Override
	public int filter(ValidateInvocation invoc) {
		if(this.userService.isForbid(invoc.getLoginUser(), invoc.getLoginSource())) {
			return LoginConstants.VALIDATE_FORBID;
		}
		return invoc.invoke();
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

}
